function formatTime(date) {
  var month = date.getMonth() + 1
  if(month<10){
    month="0"+month
  }
  var day = date.getDate()
  return  month + "-" + day;
}
const formatDay = dates => {
  let _day = new Array('星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六');
  let date = new Date(dates);
  date.setDate(date.getDate());
  let day = date.getDay();
  return _day[day];
}
function formatDateTime(inputTime) {
  var date = new Date(inputTime);
  var y = date.getFullYear();
  var m = date.getMonth() + 1;
  m = m < 10 ? "0" + m : m;
  var d = date.getDate();
  d = d < 10 ? "0" + d : d;
  // var h = date.getHours();
  // h = h < 10 ? "0" + h : h;
  // var minute = date.getMinutes();
  // var second = date.getSeconds();
  // minute = minute < 10 ? "0" + minute : minute;
  // second = second < 10 ? "0" + second : second;
  return y + "-" + m + "-" + d;
  // return y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
}
// dateset
function paddingZero(n) {
  if (n < 10) {
    return '0' + n;
  } else {
    return n;
  }
}
function getWeekDay(){
  let that=this;
  let myDate=new Date();
  let month=myDate.getMonth()+1;
  let date=myDate.getDate();
  let week=["周日","周一","周二","周三","周四","周五","周六"];
  myDate.setDate(myDate.getDate());
  let timestemp=new Date().getTime();
  let times=[];
  let dateArray=[];
  times.push(myDate,month,date,week,timestemp)
  // console.log(times)
  for(let i=0;i<31;i++){
    dateArray.push({
      "date":myDate.getDate(),
      "year":myDate.getFullYear(),
      "date_str":that.paddingZero(myDate.getMonth() + 1)+"-"+that.paddingZero(myDate.getDate()),
      "day":week[myDate.getDay()],
      "month":that.paddingZero((myDate.getMonth() + 1)),
      "time":"not set",
      "timestamp":myDate.getTime(),
    })
    myDate.setDate(myDate.getDate()+1)
  }
  // console.log(dateArray);
  return dateArray
}
module.exports = {
  formatTime: formatTime,
  formatDay: formatDay,
  formatDateTime:formatDateTime,
  paddingZero:paddingZero,
  getWeekDay:getWeekDay
}